var num =0;
var timer

//封装
function fn() {
    timer = setInterval(function(){
            num++;
        
            if(num>7)num=0;
        
            for(var i=0;i<wrap.children.length;i++){
                wrap.children[i].className='';
                box.children[i].className='';
            }
            
            wrap.children[num].className="current"
            box.children[num].className="current"
        },2000)
    }

fn();

 var left2 = document.getElementsByClassName("left2");

left2[0].onmouseover = function(){
   clearTimeout(timer)
//    console.log("qq")
}

left2[0].onmouseout  = function(){
   fn();
 }
 //小圆点
 for(var i=0;i<box.children.length;i++){
     box.children[i].index=i;
     box.children[i].onmouseover=function(){
     for(var j=0;j<box.children.length;j++){
            box.children[j].className='';
            wrap.children[j].className="";
         }
        this.className="current";
        wrap.children[this.index].className="current";
     }
 }

 //箭头

 right.onclick = function(){
    //alert("q")
    num++;
        
        if(num>7)num=0;
    
        for(var i=0;i<wrap.children.length;i++){
            wrap.children[i].className='';
            box.children[i].className='';
        }
        
        wrap.children[num].className="current"
        box.children[num].className="current"
};

left.onclick = function(){
    //alert("q")
    num--;
        
        if(num<0)num=7;
    
        for(var i=0;i<wrap.children.length;i++){
            wrap.children[i].className='';
            box.children[i].className='';
        }
        
        wrap.children[num].className="current"
        box.children[num].className="current"
};

//实先倒计时
setInterval(function(){
    var currentTime = new Date();
    var deadtime =  new Date(2021,06,19,18,0,0);
    // console.log(deadtime);
    
    var t=deadtime.getTime()-currentTime.getTime();
    
     
 
    var hours =parseInt((t%(1000*60*60*24))/(1000*60*60));
    
       var minutes =parseInt((t%(1000*60*60))/(1000*60));

    var seconds = parseInt((t%(1000*60))/(1000));
    // var minutes = parseInt((t%(1000*60*60*24))/(1000*60));
    
    // var seconds = parseInt((t%(1000*60*60*24))/(1000));
    
    // console.log(hours)
    if(hours<10){
        h.innerHTML ='0' + hours;
    } else {
        h.innerHTML = hours;
    };
    
    if(minutes<10){
        m.innerHTML ='0' + minutes;
    } else {
        m.innerHTML = minutes;
    };
    
    if(seconds<10){
        s.innerHTML ='0' + seconds;
    } else {
        s.innerHTML = seconds;
    };
    
    
},1000)

//点击效果
for(var t=0; t<pricetop.children.length;t++){
    pricetop.children[t].index=t;

    pricetop.children[t].onmouseover = function(){
        for(var i=0;i<pricetop.children.length;i++){
            pricetop.children[i].className='';
            bottom.children[i].className='';
        }
        this.className = 'current';
        var index=this.index;
        bottom.children[index].className='current';
    }
}

//发现好货
var fg=0;
var times;

function fns(){
    times=setInterval(function(){
    fg+=4;
    if(fg>1980)fg=0;
    fgood.style.transform='translate('+-fg+'px)'
},40)

}

fns();

fgood.onmouseover = function(){
    clearTimeout(times)
 //    console.log("qq")
 }
 fgood.onmouseout  = function(){
    fns();
  }

//点击效果
for(var t=0; t<recomment.children.length;t++){
    recomment.children[t].index=t;

    recomment.children[t].onmouseover = function(){
        for(var i=0;i<recomment.children.length;i++){
            recomment.children[i].className='';
            bottom2.children[i].className='';
        }
        this.className = 'current';
        var index=this.index;
        bottom2.children[index].className='current';
    }
}
for(var t=0; t<aside.children.length;t++){
    aside.children[t].index=t;

    aside.children[t].onmouseover = function(){
        for(var i=0;i<aside.children.length;i++){
            aside.children[i].style.background='';
            console.log(12)
        }
        this.style.background = 'red';
       
    }
}

